﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SEOBlog.Services;
using SEOBlog.Web.Models;
using SEOBlog.Web.Models.Admin;

namespace SEOBlog.Web.Controllers
{
    public class AdminController : Controller
    {
        private PagesService _pagesService = new PagesService();

        [HttpGet]
        public ActionResult Index()
        {
            var allPages = _pagesService.GetAllPages();

            var model = new PageTreeViewModel
                            {
                                Nodes = allPages.Select(x => new PageTreeViewNode
                                                                 {
                                                                     Id = x.Id.ToString(),
                                                                     Name = x.MenuTitle,
                                                                     ParentId = x.ParentId.ToString(),
                                                                     Url = x.FriendlyUrl
                                                                 })
                            };

            return View(model);
        }
        
        [HttpGet]
        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create(NewPageViewModel newPage)
        {
            return View();
        }

        [HttpGet]
        public ActionResult Edit()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Edit(NewPageViewModel newPage)
        {
            return View();
        }
    }
}
